#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<unordered_set>
using namespace std;
const int N = 21, M = 1e6 + 10, mod = 1e9;
int f[M];
int m;
int main()
{
    cin >> m;
    f[0] = 1;
    for (int v = 1; v <= m; v *= 2)
    {
        for (int j = v; j <= m; j++)
        {
            f[j] = (f[j] + f[j - v]) % mod;
        }
    }
    cout << f[m] << endl;
    return 0;
}